<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * 装修模型
 */
class Finish extends Model
{
    protected $guarded = [];
    /**
     * 多条件查询
     * gao
     * @param array $where
     * @return mixed
     */
    public static function findList(array $where)
    {
        return self::where($where)->where('is_del', '0')->get()->toArray();
    }

    /**
     * 获取详情数据
     * gao
     * @param $id
     * @return mixed
     */
    public static function getOne($id)
    {
        return self::where('is_del', '0')->find($id);
    }

    /**
     * 获取未删除的所有数据
     * gao
     * @return mixed
     */
    public static function getAll()
    {
        return self::where('is_del', '0')->get();
    }

    /**
     * 添加一条数据
     * gao
     * @param $params
     * @return mixed
     */
    public static function addOne(array $params)
    {
        return self::create($params);
    }

    /**
     * 更新一条数据
     * gao
     * @param $where
     * @param $params
     * @return mixed
     */
    public static function saveOne($where, $params)
    {
        return self::where($where)->where('is_del', '0')->update($params);
    }

    /**
     * 删除一条数据
     * gao
     * @param $id
     * @return int
     */
    public static function delOne($id)
    {
        return self::where('id', $id)
            ->where('is_del', '0')
            ->update(['is_del' => '1']);
    }

}
